<template>
    <div class="case-lists">
        <template v-if="casesData && casesData.length">
            <list-item
                v-for="(item, index) in casesData"
                :key="index"
                :itemData="item"
            ></list-item>
            <el-pagination
                background
                @current-change="handleCurrentChange"
                layout="pager, next"
                :total="total"
            >
            </el-pagination>
        </template>
        <div v-else class="p-30 txt-info">暂无案例~</div>
    </div>
</template>

<script>
    import ListItem from './ListItem'
    export default {
        name: 'caseLists',
        components: {
            ListItem,
        },
        data() {
            return {
                total: 0,
                pageSize: 5,
                currentPage: 1,
                casesData: [],
            }
        },
        methods: {
            getCasesData() {
                var datamsg = {
                    currentPage: this.currentPage,
                    pageSize: this.pageSize,
                    param: '',
                    CASE_STUTS: '1',
                    isShow: true,
                }
                this.$http
                    .getCaseLists({ datamsg: JSON.stringify(datamsg) })
                    .then((res) => {
                        console.log(res)
                        if (res.success) {
                            this.casesData = res.data.goods_list
                            this.total = res.data.total
                        }
                    })
                    .catch((err) => {
                        this.$msgAlert(err)
                    })
            },
            handleCurrentChange(val) {
                this.currentPage = val
                this.getCasesData()
            },
        },
        mounted() {
            this.getCasesData()
        },
    }
</script>

<style>
    .case-lists {
        margin-top: 20px;
        min-height: 400px;
    }
    .el-pagination {
        margin: 30px 0 60px;
    }
</style>